home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / boot / shadowstart12.lha / ShadowStart12 / 3.1 / ShadowStart.c next >
Encoding:
C/C++ Source or Header  |  1994-12-10  |  4.6 KB  |  134 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Lars Eilebrecht (Shadowfox)
  4. **
  5. ** File             : Work:Program/SC/PRG/ShadowStart/ShadowStart.c
  6. ** Created on       : Mittwoch, 16.11.94 17:23:09
  7. ** Created by       : Lars Eilebrecht
  8. ** Current revision : V1.2
  9. **
  10. **
  11. ** Purpose
  12. ** -------
  13. **     Disable "WBStartup" and/or "User-Startup" during startup. (V40)
  14. **
  15. ** Revision V1.2
  16. ** --------------
  17. ** created on Freitag, 09.12.94 01:06:44  by  Lars Eilebrecht.   LogMessage :
  18. **   - minor code changes
  19. **
  20. ** Revision V1.1
  21. ** --------------
  22. ** created on Montag, 28.11.94 18:58:55  by  Lars Eilebrecht.   LogMessage :
  23. **  -*-  changed on Samstag, 03.12.94 22:12:20  by  Lars Eilebrecht.   LogMessage :
  24. **   - recompiled ShadowStart without startup-code
  25. **     (results in a shorter executable)
  26. **  -*-  created on Montag, 28.11.94 18:58:55  by  Lars Eilebrecht.   LogMessage :
  27. **   - added NewShell-button
  28. **     renamed other buttons, so that it fit on a lores-screen
  29. **     removed stdio.h include (shorter executable)
  30. **     cleaned up code a little
  31. **
  32. ** Revision V1.0
  33. ** --------------
  34. ** created on Mittwoch, 16.11.94 17:23:09  by  Lars Eilebrecht.   LogMessage :
  35. **     --- Initial release ---
  36. **
  37. *********************************************************************************/
  38. #define REVISION "1.2"
  39. #define REVDATE  "09.12.94"
  40. #define REVTIME  "01:06:44"
  41. #define AUTHOR   "Lars Eilebrecht"
  42. #define VERNUM   1
  43. #define REVNUM   2
  44. #define TITLE "ShadowStart "REVISION" ("REVDATE") (V40) © by "AUTHOR" (Shadowfox)"
  45.  
  46. #include <exec/types.h>
  47. #include <intuition/intuition.h>
  48. #include <libraries/lowlevel.h>
  49. #include <libraries/dos.h>
  50.  
  51. #include <pragmas/exec_pragmas.h>
  52. #include <pragmas/dos_pragmas.h>
  53. #include <pragmas/intuition_pragmas.h>
  54. #include <pragmas/lowlevel_pragmas.h>
  55.  
  56. #include <clib/exec_protos.h>
  57. #include <clib/dos_protos.h>
  58. #include <clib/intuition_protos.h>
  59. #include <clib/lowlevel_protos.h>
  60.  
  61. static const char *ver ="$VER: "TITLE"\0";
  62.  
  63. int ShadowStart(void)
  64. {
  65.   LONG rc=RETURN_FAIL;
  66.  
  67.   struct Library *DOSBase;
  68.  
  69.   if(DOSBase=OpenLibrary("dos.library",37))
  70.   {
  71.     struct Library *LowLevelBase;
  72.  
  73.     if(LowLevelBase=OpenLibrary("lowlevel.library",40))
  74.     {
  75.       struct Library *IntuitionBase;   
  76.  
  77.       if(IntuitionBase=OpenLibrary("intuition.library",37))
  78.       {
  79.         struct KeyQuery spacebar =                      // declare KeyQuery-struct
  80.                         {
  81.                           (UWORD)64,                    // rawkeycode for spacebar
  82.                           FALSE,                        // not pressed yet...
  83.                         };
  84.  
  85.         rc=RETURN_OK;
  86.         if(Rename("SYS:_WBStartup","SYS:WBStartup"))    // rename to original names...
  87.           Rename("SYS:_WBStartup.info","SYS:WBStartup.info");
  88.         Rename("SYS:S/_User-Startup","SYS:S/User-Startup");
  89.  
  90.         QueryKeys(&spacebar,(UBYTE)1);                  // dirty spacebar check ;-)
  91.         if(spacebar.kq_Pressed)                         // Was it pressed? Silent exit, if not...
  92.         {
  93.           LONG result;
  94.  
  95.           struct EasyStruct shadowES =                  // declare EasyRequest-struct
  96.                             {
  97.                               sizeof(struct EasyStruct),
  98.                               0, // no flags
  99.                               "ShadowStart "REVISION" ("REVDATE") © by Lars `SFX' Eilebrecht",
  100.                               "\nSelect startup-items that should be disabled\n\nor select `NewShell' to open a shell-window\n",
  101.                               "WB + User|WB|User|NewShell|Cancel",
  102.                             };
  103.  
  104.           result=EasyRequest(NULL,&shadowES,NULL);
  105.           switch (result)
  106.           {                 // note: success of rename-operation isn't checked...
  107.             case 1: 
  108.               Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
  109.             case 2:
  110.               Rename("SYS:WBStartup","SYS:_WBStartup");
  111.               Rename("SYS:WBStartup.info","SYS:_WBStartup.info");
  112.               break;
  113.             case 3:
  114.               Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
  115.               break;
  116.             case 4:
  117.               if(!Execute("NewShell",0,0))              // open a shell-window...
  118.                 rc=RETURN_FAIL;
  119.               Wait(SIGBREAKF_CTRL_C);                   // 'hold' startup-sequence...
  120.           }
  121.         }
  122.         CloseLibrary(IntuitionBase);
  123.       }
  124.       else
  125.         PrintFault(ERROR_INVALID_RESIDENT_LIBRARY,"intuition.library");
  126.       CloseLibrary(LowLevelBase);
  127.     }
  128.     else
  129.       PrintFault(ERROR_INVALID_RESIDENT_LIBRARY,"lowlevel.library");
  130.     CloseLibrary(DOSBase);
  131.   }
  132.   return(rc);
  133. }
  134.